Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

186
Visualizações
Firebase Functions, Parsing error: Unexpected token =>

I'm building my first firebase function with Js to handle card payments with Checkout.com API, I've installed both checkout and firebase JavaScript SDK's and this is my index.js folder:

const functions = require("firebase-functions");
const { Checkout } = require("checkout-sdk-node");
const cko = new Checkout("sk_test_XXXXX-XXXX-XXXX");

exports.payWithToken = functions.https.onCall(async (data, context) => {
    try {
        const payment = await cko.payments.request({
            source: {
                token: data.token,
            },
            customer: {
                email: context.auth.token.email
            },
            currency: data.currency,
            amount: data.amount,
        })
        return {
            "Status": payment.status,
            "3DS-Link": payment.redirectLink,
            "Approved": approved,
            "Flagged": risk.flagged,
        };
    } catch (error) {
        console.log(error)
        throw new functions.https.HttpsError(error.name, error.message, error);
    }
});

I think I followed the documentation correctly but for some reason, I couldn't deploy this function to firebase and I get this error:

Parsing error: Unexpected token =>

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

In package.json,

change this

    "lint": "eslint .",

to this

    "lint": "eslint",
about 4 years ago · Juan Pablo Isaza Relatório

0

I found the solution on this page.

Essentially

Arrow functions are an ES6 feature, but here you have an async arrow function.

Async functions in general are an ES8 (or 2017) feature. Therefore you need to specify the following setting at the root of your config: parserOptions: { ecmaVersion: 8 // or 2017 }

So I needed to update my .eslintrc.js file to this

module.exports = {
  root: true,
  env: {
    es6: true,
    node: true
  },
  parserOptions: {
    ecmaVersion: 8
  },
  extends: ['eslint:recommended', 'google'],
  rules: {
    'comma-dangle': 'off',
    'quote-props': 'off',
    indent: ['error', 2]
  }
};
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda